// 示例项目数据
const projects = [
    {
        id: '135416710',
        title: '音乐创作器',
        author: 'MusicMaker',
        description: '一个交互式音乐创作工具，可以组合不同的乐器声音，创作独特的音乐作品。',
        likes: 421,
        comments: 89,
        stars: 132
    },
    {
        id: 'example4',
        title: '数学解谜',
        author: 'MathWizard',
        description: '通过解决有趣的数学谜题来提升计算能力，适合各个年龄段的学习者。',
        likes: 198,
        comments: 34,
        stars: 56
    },
    {
        id: 'example5',
        title: '海底世界',
        author: 'OceanLover',
        description: '探索丰富多彩的海底世界，了解海洋生物，完成环保主题的小任务。',
        likes: 367,
        comments: 78,
        stars: 91
    },
    {
        id: 'example6',
        title: '绘画板',
        author: 'ArtCreator',
        description: '一个功能丰富的绘画工具，支持多种笔刷和颜色，让创作变得简单有趣。',
        likes: 245,
        comments: 56,
        stars: 78
    },
    {
        id: 'example7',
        title: '迷宫探险',
        author: 'MazeRunner',
        description: '一个具有挑战性的迷宫游戏，玩家需要找到通往终点的路径，同时收集宝藏和躲避陷阱。',
        likes: 312,
        comments: 67,
        stars: 89
    },
    {
        id: 'example8',
        title: '动物农场',
        author: 'FarmKeeper',
        description: '经营你自己的虚拟农场，照顾可爱的动物，种植农作物，体验农场生活的乐趣。',
        likes: 428,
        comments: 92,
        stars: 156
    },
    {
        id: 'example9',
        title: '科学实验室',
        author: 'ScienceLab',
        description: '通过互动实验学习基础物理概念，包括力学、光学和声学等多个主题。',
        likes: 276,
        comments: 58,
        stars: 83
    },
    {
        id: 'example10',
        title: '故事创作器',
        author: 'StoryTeller',
        description: '创建你自己的互动故事，设计角色、场景和对话，让故事栩栩如生。',
        likes: 389,
        comments: 84,
        stars: 127
    },
    {
        id: 'example11',
        title: '节奏大师',
        author: 'RhythmKing',
        description: '一个音乐节奏游戏，跟随音乐节拍点击，提升音乐感和反应能力。',
        likes: 467,
        comments: 103,
        stars: 178
    },
    {
        id: 'example12',
        title: '编程启蒙',
        author: 'CodeTeacher',
        description: '专为初学者设计的编程教程，通过简单有趣的任务学习基础编程概念。',
        likes: 534,
        comments: 147,
        stars: 203
    },
    {
        id: 'example13',
        title: '环保卫士',
        author: 'EcoHero',
        description: '一个环保主题的教育游戏，学习垃圾分类、节能减排等环保知识。',
        likes: 298,
        comments: 64,
        stars: 91
    },
    {
        id: 'example14',
        title: '数独挑战',
        author: 'SudokuMaster',
        description: '经典数独游戏，提供多个难度等级，训练逻辑思维能力。',
        likes: 245,
        comments: 52,
        stars: 76
    },
    {
        id: 'example15',
        title: '虚拟宠物',
        author: 'PetLover',
        description: '照顾你的虚拟宠物，喂食、玩耍、训练，让它健康快乐地成长。',
        likes: 487,
        comments: 126,
        stars: 164
    },
    {
        id: 'example16',
        title: '天气预报站',
        author: 'WeatherWatcher',
        description: '学习气象知识，观察天气变化，预测天气现象的互动项目。',
        likes: 234,
        comments: 48,
        stars: 72
    },
    {
        id: 'example17',
        title: '篮球投篮',
        author: 'BasketballPro',
        description: '考验手眼协调能力的投篮游戏，包含多个关卡和不同的挑战模式。',
        likes: 378,
        comments: 82,
        stars: 115
    },
    {
        id: 'example18',
        title: '词语接龙',
        author: 'WordMaster',
        description: '中文词语接龙游戏，增加词汇量，训练反应速度和语言能力。',
        likes: 289,
        comments: 63,
        stars: 94
    },
    {
        id: 'example19',
        title: '几何艺术',
        author: 'GeoArtist',
        description: '使用几何图形创作艺术作品，学习基础几何知识和艺术设计。',
        likes: 342,
        comments: 71,
        stars: 108
    },
    {
        id: 'example20',
        title: '记忆训练',
        author: 'MemoryTrainer',
        description: '通过有趣的配对游戏和序列记忆训练提升记忆力。',
        likes: 256,
        comments: 54,
        stars: 82
    },
    {
        id: 'example21',
        title: '化学实验室',
        author: 'ChemistryLab',
        description: '虚拟化学实验室，安全地进行各种化学反应实验和观察。',
        likes: 312,
        comments: 68,
        stars: 97
    }
];

// 动态加载更多项目
function loadProjects() {
    const projectGrid = document.querySelector('.project-grid');
    
    projects.forEach(project => {
        const projectCard = document.createElement('div');
        projectCard.className = 'project-card';
        projectCard.innerHTML = `
            <div class="project-preview">
                <iframe src="https://scratch.mit.edu/projects/embed/${project.id}" 
                        allowtransparency="true" 
                        frameborder="0" 
                        scrolling="no" 
                        allowfullscreen></iframe>
            </div>
            <div class="project-info">
                <h3>${project.title}</h3>
                <p class="author">作者：${project.author}</p>
                <p class="description">${project.description}</p>
                <div class="stats">
                    <span>👍 ${project.likes}</span>
                    <span>💬 ${project.comments}</span>
                    <span>⭐ ${project.stars}</span>
                </div>
            </div>
        `;
        projectGrid.appendChild(projectCard);
    });
}

// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', () => {
    loadProjects();
});

// 导航栏活跃状态切换
const navLinks = document.querySelectorAll('nav a');
navLinks.forEach(link => {
    link.addEventListener('click', (e) => {
        e.preventDefault();
        navLinks.forEach(l => l.classList.remove('active'));
        link.classList.add('active');
    });
});